<template>
  <div>
    <el-drawer
      title="详情"
      :before-close="handleClose"
      :visible.sync="dialog"
      direction="rtl"
      custom-class="drawer"
      ref="drawer"
    >
      <div class="drawer__content">
        <el-form :model="form">
          <el-form-item label="系统名称:" :label-width="formLabelWidth">
            <el-tag type="success">
              <i class="el-icon-s-home"></i>
              {{ SystemName }}</el-tag
            >
          </el-form-item>
          <el-form-item label="菜单类型:" :label-width="formLabelWidth">
            <span v-if="form.ModulesType == 0">目录</span>
            <span v-if="form.ModulesType == 1">菜单</span>
            <span v-if="form.ModulesType == 2">按钮</span>
          </el-form-item>
          <el-form-item label="上级菜单:" :label-width="formLabelWidth">
            <span>{{ form.TopModulesName }}</span>
          </el-form-item>

          <el-form-item label="名称:" :label-width="formLabelWidth">
            <span>{{ form.ModulesName }}</span>
          </el-form-item>
          <el-form-item
            label="请求方式:"
            :label-width="formLabelWidth"
            v-if="form.ModulesType == '2'"
          >
            <span>{{ form.RequestMethod }}</span>
          </el-form-item>
          <el-form-item
            label="链接地址:"
            :label-width="formLabelWidth"
            v-if="form.ModulesType == '1' || form.ModulesType == '2'"
          >
            <span>{{ form.LinkUrl }}</span>
          </el-form-item>
          <el-form-item
            label="授权标识:"
            :label-width="formLabelWidth"
            v-if="form.ModulesType == '1' || form.ModulesType == '2'"
          >
            <span>{{ form.PermissionCode }}</span>
          </el-form-item>
          <el-form-item
            label="路由名称:"
            :label-width="formLabelWidth"
            v-if="form.ModulesType == '1' || form.ModulesType == '2'"
          >
            <span>{{ form.Action }}</span>
          </el-form-item>
          <el-form-item
            label="控制器名称:"
            :label-width="formLabelWidth"
            v-if="form.ModulesType == 2"
          >
            <span>{{ form.Controller }}</span>
          </el-form-item>
          <el-form-item
            label="是否授权:"
            :label-width="formLabelWidth"
            v-if="form.ModulesType == '2'"
          >
            <span>{{ form.NeedAuthorization ? "是" : "否" }}</span>
          </el-form-item>

          <el-form-item label="状态:" :label-width="formLabelWidth">
            <span>{{ form.Status ? "启用" : "禁用" }}</span>
          </el-form-item>
          <el-form-item label="排序:" :label-width="formLabelWidth">
            <span>{{ form.OrderSort }}</span>
          </el-form-item>
          <el-form-item label="备注:" :label-width="formLabelWidth">
            <span>{{ form.Description }}</span>
          </el-form-item>
        </el-form>

        <div class="drawer__footer">
          <el-button @click="cancelForm" style="width: 45%">返 回</el-button>
          <el-button style="width: 45%" type="primary" @click="edit"
            >编 辑</el-button
          >
        </div>
      </div>
    </el-drawer>
    <addMenu ref="addMenu" @editData="editData" />
  </div>
</template>

<script>
import { AccessModules_get } from "@/api/business";
import addMenu from "./addMenu";
export default {
  components: { addMenu },
  name: "",
  data() {
    return {
      dialog: false,
      loading: false,
      form: {},
      SystemName: JSON.parse(localStorage.getItem("xmGlDetails")).SystemName,
      formLabelWidth: "100px",
    };
  },
  mounted() {},
  methods: {
    show(data) {
      this.dialog = true;
      this.id = data.Id;
      this.getData(this.id);
      // let res = await AccessModules_get(data.Id);
      // this.form = res.data.response;
    },
    editData() {
      this.getData(this.id);
      this.$emit("getData");
    },
    async getData(id) {
      let res = await AccessModules_get(id);
      this.form = res.data.response;
    },
    handleClose(done) {
      this.dialog = false;
      // this.$emit("getData");
    },
    cancelForm() {
      this.loading = false;
      this.dialog = false;
      // this.$emit("getData");
    },
    edit() {
      this.$refs.addMenu.show(this.form);
    },
  },
};
</script>

<style  scoped>
.drawer__footer {
  width: 100%;
  text-align: center;
  position: absolute;
  bottom: 12px;
}
/deep/ .el-form-item__label {
  font-size: 15px;
}
</style>
